﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using DnD.ViewModels;

namespace DnD
{
    public partial class CardPage : PhoneApplicationPage
    {
        public CardPage()
        {
            InitializeComponent();
        }


        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            string cardIDString;
            if (NavigationContext.QueryString.TryGetValue("cardID", out cardIDString))
             {
                int cardID;
                if(int.TryParse(cardIDString, out cardID))
                {
                    DataContext = new CardViewModel(cardID,this,false);
                }
                 
            }  
        }

        private void CardView_Hold(object sender, System.Windows.Input.GestureEventArgs e)
        {
            ((CardViewModel)DataContext).editCard();
        }

       
    }
}